package org.custom.spring.boot.mybatis.config;

import org.apache.ibatis.plugin.Interceptor;
import org.custom.spring.boot.mybatis.plugin.impl.MybatisExecuteLoggerPlugIn;
import org.custom.spring.boot.mybatis.plugin.impl.MybatisOptimisticLockPlugin;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 系统相关配置
 *
 * @author LiKun
 */
@Configuration
@MapperScan("com.spring.boot.mybatis.mapper")
public class SystemConfig {
    /**
     * 将Mybatis插件注入MyBatis拦截器链
     *
     * @return 拦截器
     */
    @Bean
    public Interceptor[] interceptors() {
        return new Interceptor[]{new MybatisExecuteLoggerPlugIn(), new MybatisOptimisticLockPlugin()};
    }
}
